<template>
  <el-form ref="formRef" :model="formModel" :rules="rules" label-width="120px" class="form" label-position="right" status-icon>
    <el-form-item label="提现申请人:" class="form-item">
      {{ bankInfo.dispatcherName }}
    </el-form-item>
    <el-form-item label="收款账户:" class="form-item">
      <div>开户行：{{ bankInfo.openBank }}</div>
      <div>银行卡号：{{ bankInfo.bankCardNo }}</div>
      <div>开户姓名：{{ bankInfo.bankName }}</div>
    </el-form-item>
    <el-form-item label="申请金额:" class="form-item">{{ formModel.money }}元</el-form-item>
    <el-form-item label="扣款金额:" class="form-item">
      {{ formModel.deductionsMoney }}元
      <span class="input-info">* 扣款金额 = 实际扣款额度 +（微信手续费默认扣除千分之6，最低1元钱）</span>
    </el-form-item>
    <el-form-item label="扣款说明:">
      {{ formModel.deductionsRemark }}
    </el-form-item>
    <el-form-item label="实际打款金额:" prop="actualMoney" class="form-select">
      <el-input v-model.trim="formModel.actualMoney" placeholder="请输入实际打款金额">
        <template slot="append">元</template>
      </el-input>
    </el-form-item>
    <el-form-item label="上传凭证:" prop="certificatesUrl">
      <el-input v-model.trim="formModel.certificatesUrl" placeholder="请输入上传凭证地址"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
import MixinForm from 'mixins/form'

export default {
  mixins: [MixinForm],
  props: {
    initData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      bankInfo: {},
      rules: {
        actualMoney: [{ required: true, message: '审核备注不能为空', trigger: 'blur' }],
        certificatesUrl: [{ required: true, message: '打款凭证不能为空', trigger: 'blur' }]
      }
    }
  },
  computed: {
    formModel: {
      get() {
        return this.initData
      },
      set(val) {
        this.$emit('update:init-data', val)
      }
    }
  },
  created() {
    this.queryBankCard()
    const { money, deductionsMoney } = this.formModel
    console.log(money, deductionsMoney)
    this.formModel.actualMoney = ((money.replace(',', '') * 100 - deductionsMoney.replace(',', '') * 100) / 100).toFixed(2)
  },
  methods: {
    queryBankCard() {
      const { dispatcherId } = this.initData
      this.$api.vehicle
        .fetch('queryDispatcherBankCard', {
          dispatcherId
        })
        .then(res => {
          const { dispatcherName, openBank, bankCardNo, bankName } = res
          this.bankInfo = {
            dispatcherName,
            openBank,
            bankCardNo,
            bankName
          }
        })
    }
  }
}
</script>

<style lang="less" scoped>
.form {
  .form-item {
    width: 100%;
    margin-bottom: 0px;
  }
  .form-select {
    width: 50%;
  }
}
</style>
